﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Media.DirectShow.Filters;
using System.Windows.Media.DirectShow;

namespace Test
{
    public partial class ElementCapturePage : UserControl
    {

        private FilterGraph graph;
        private ElementCaptureSource sourceFilter;

        public ElementCapturePage()
        {
            InitializeComponent();

            graph = new FilterGraph();

            sourceFilter = new ElementCaptureSource();
            graph.AddFilter("source", sourceFilter);

            VideoAudioRenderer render = new VideoAudioRenderer();
            graph.AddFilter("render", render);
            graph.ConnectFilters(sourceFilter, render, MediaMajorTypes.Video);
            video.Child = render.UIElement;
            this.Loaded += new RoutedEventHandler(CapturePage_Loaded);
        }

        void CapturePage_Loaded(object sender, RoutedEventArgs e)
        {
            text.UpdateLayout();
            sourceFilter.SetElement(text, 12d);

            graph.RunAsync();
        }
    }
}
